//全屏
export const screenFullEnter = () => {
  const doc: any = document.documentElement;
  if (doc.requestFullscreen) {
    doc.requestFullscreen();
  }
  //FireFox
  else if (doc.mozRequestFullScreen) {
    doc.mozRequestFullScreen();
  }
  //Chrome等
  else if (doc.webkitRequestFullScreen) {
    doc.webkitRequestFullScreen();
  }
  //IE11
  else if (doc.msRequestFullscreen) {
    doc.msRequestFullscreen();
  }
};
//推出全屏
export const exitsScreenFull = () => {
  const doc: any = document;
  if (doc.exitFullscreen) {
    doc.exitFullscreen();
  }
  // Chrome
  else if (doc.webkitCancelFullScreen) {
    doc.webkitCancelFullScreen();
  }
  // firefox
  else if (doc.mozCancelFullScreen) {
    doc.mozCancelFullScreen();
  }
  // IE
  else if (doc.msExitFullscreen) {
    doc.msExitFullscreen();
  }
};

/**
 * 是否为本地模式
 */
export const isNative = () => {
  if (window.nw) {
    return true;
  } else {
    return false;
  }
};

export const defaultUrlValue = (value: any, secondValue: any) => {
  return isNative() ? value : secondValue;
};
//度转度°分′秒″
export const ToDegrees = (val: any, unit: any) => {
  if (typeof val == "undefined" || val == "") {
    return "";
  }
  var i = val.indexOf(".");

  if (val) var strDu = i < 0 ? val : val.substring(0, i); //获取度
  var strFen: any = 0;
  var strMiao: any = 0;
  if (i > 0) {
    strFen = "0" + val.substring(i);
    strFen = strFen * 60 + "";
    i = strFen.indexOf(".");
    if (i > 0) {
      strMiao = "0" + strFen.substring(i);
      strFen = strFen.substring(0, i); //获取分
      strMiao = strMiao * 60 + "";
      i = strMiao.indexOf(".");
      strMiao = strMiao.substring(0, i + 4); //取到小数点后面三位
      strMiao = parseFloat(strMiao).toFixed(0); //精确小数点后面两位
    }
  }
  return strDu + "°" + strFen + "′" + strMiao + "″" + unit; // 这里可以修改成你想要的格式例如你可以
  //    改成这样的：return strDu + "°" + strFen + "'" + strMiao + "\"N";
};
export default {
  screenFullEnter,
  exitsScreenFull,
  ToDegrees,
};
